<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-button v-if="isAuth('eas:easbasicteacher:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
        <el-button v-if="isAuth('eas:easbasicteacher:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column>
      <el-table-column
        prop="id"
        header-align="center"
        align="center"
        label="老师id">
      </el-table-column>
      <el-table-column
        prop="userId"
        header-align="center"
        align="center"
        label="用户id">
      </el-table-column>
      <el-table-column
        prop="teacherName"
        header-align="center"
        align="center"
        label="老师姓名">
      </el-table-column>
      <el-table-column
        prop="code"
        header-align="center"
        align="center"
        label="代码">
      </el-table-column>
      <el-table-column
        prop="roleAlias"
        header-align="center"
        align="center"
        label="角色别名">
      </el-table-column>
      <el-table-column
        prop="status"
        header-align="center"
        align="center"
        label="状态, 1:正常,2:停用,3:回收站,4:删除(关闭数据),5:退休,6:离职,7:调岗,8:出国,9:身故,10:暂未在本单位任职-借出到机关,11:暂未在本单位任职-借出到事业单位,12:暂未在本单位任职-长病假13:暂未在本单位任职-进修,14:暂未在本单位任职-交流轮岗,15:暂未在本单位任职-企业实践,16:暂未在本单位任职-因公出国,17:暂未在本单位任职-离岗创业,18:暂未在本单位任职-待退休,19:暂未在本单位任职-待岗,20:暂未在本单位任职-下落不明,21:离休,22:返聘,23:暂未在本单位任职,24:其他">
      </el-table-column>
      <el-table-column
        prop="gender"
        header-align="center"
        align="center"
        label="性别：1：男性；2：女性；0：保密。">
      </el-table-column>
      <el-table-column
        prop="avatar"
        header-align="center"
        align="center"
        label="头像">
      </el-table-column>
      <el-table-column
        prop="parameter"
        header-align="center"
        align="center"
        label="虚拟扩展字段">
      </el-table-column>
      <el-table-column
        prop="mobile"
        header-align="center"
        align="center"
        label="手机号码">
      </el-table-column>
      <el-table-column
        prop="mail"
        header-align="center"
        align="center"
        label="邮箱">
      </el-table-column>
      <el-table-column
        prop="address"
        header-align="center"
        align="center"
        label="通讯地址">
      </el-table-column>
      <el-table-column
        prop="post"
        header-align="center"
        align="center"
        label="邮编">
      </el-table-column>
      <el-table-column
        prop="remark"
        header-align="center"
        align="center"
        label="备注信息">
      </el-table-column>
      <el-table-column
        prop="formerName"
        header-align="center"
        align="center"
        label="曾用名">
      </el-table-column>
      <el-table-column
        prop="country"
        header-align="center"
        align="center"
        label="国籍/地区">
      </el-table-column>
      <el-table-column
        prop="hometown"
        header-align="center"
        align="center"
        label="籍贯">
      </el-table-column>
      <el-table-column
        prop="nation"
        header-align="center"
        align="center"
        label="民族">
      </el-table-column>
      <el-table-column
        prop="birthDate"
        header-align="center"
        align="center"
        label="出生日期">
      </el-table-column>
      <el-table-column
        prop="birthCode"
        header-align="center"
        align="center"
        label="出生行政地编码">
      </el-table-column>
      <el-table-column
        prop="paperworkType"
        header-align="center"
        align="center"
        label="证件类型">
      </el-table-column>
      <el-table-column
        prop="paperworkSn"
        header-align="center"
        align="center"
        label="证件编号">
      </el-table-column>
      <el-table-column
        prop="healthStatus"
        header-align="center"
        align="center"
        label="健康状态">
      </el-table-column>
      <el-table-column
        prop="workYear"
        header-align="center"
        align="center"
        label="工龄">
      </el-table-column>
      <el-table-column
        prop="characterType"
        header-align="center"
        align="center"
        label="政治面貌">
      </el-table-column>
      <el-table-column
        prop="partTime"
        header-align="center"
        align="center"
        label="入党时间">
      </el-table-column>
      <el-table-column
        prop="maritalStatus"
        header-align="center"
        align="center"
        label="婚姻状态">
      </el-table-column>
      <el-table-column
        prop="graduateDate"
        header-align="center"
        align="center"
        label="毕业时间">
      </el-table-column>
      <el-table-column
        prop="college"
        header-align="center"
        align="center"
        label="毕业院校">
      </el-table-column>
      <el-table-column
        prop="major"
        header-align="center"
        align="center"
        label="所学专业">
      </el-table-column>
      <el-table-column
        prop="eduType"
        header-align="center"
        align="center"
        label="学历类型">
      </el-table-column>
      <el-table-column
        prop="eduName"
        header-align="center"
        align="center"
        label="学历名称">
      </el-table-column>
      <el-table-column
        prop="eduLevel"
        header-align="center"
        align="center"
        label="学历层次">
      </el-table-column>
      <el-table-column
        prop="levelName"
        header-align="center"
        align="center"
        label="学历层次名称">
      </el-table-column>
      <el-table-column
        prop="degreeType"
        header-align="center"
        align="center"
        label="学位类型">
      </el-table-column>
      <el-table-column
        prop="degreeDate"
        header-align="center"
        align="center"
        label="学位时间">
      </el-table-column>
      <el-table-column
        prop="primaryClazzify"
        header-align="center"
        align="center"
        label="一级分类">
      </el-table-column>
      <el-table-column
        prop="secondaryClazzify"
        header-align="center"
        align="center"
        label="二级分类">
      </el-table-column>
      <el-table-column
        prop="type"
        header-align="center"
        align="center"
        label="教职类别">
      </el-table-column>
      <el-table-column
        prop="orgin"
        header-align="center"
        align="center"
        label="教职来源">
      </el-table-column>
      <el-table-column
        prop="schemeType"
        header-align="center"
        align="center"
        label="编制类型">
      </el-table-column>
      <el-table-column
        prop="grade"
        header-align="center"
        align="center"
        label="职称等级">
      </el-table-column>
      <el-table-column
        prop="professional"
        header-align="center"
        align="center"
        label="职称">
      </el-table-column>
      <el-table-column
        prop="metier"
        header-align="center"
        align="center"
        label="从教专业">
      </el-table-column>
      <el-table-column
        prop="subject"
        header-align="center"
        align="center"
        label="从教学科">
      </el-table-column>
      <el-table-column
        prop="staffWay"
        header-align="center"
        align="center"
        label="用人形式">
      </el-table-column>
      <el-table-column
        prop="staffFeature"
        header-align="center"
        align="center"
        label="人员性质">
      </el-table-column>
      <el-table-column
        prop="staffKind"
        header-align="center"
        align="center"
        label="人员类别">
      </el-table-column>
      <el-table-column
        prop="staffType"
        header-align="center"
        align="center"
        label="人员类型">
      </el-table-column>
      <el-table-column
        prop="jobKind"
        header-align="center"
        align="center"
        label="岗位类别">
      </el-table-column>
      <el-table-column
        prop="jobGrade"
        header-align="center"
        align="center"
        label="岗位等级">
      </el-table-column>
      <el-table-column
        prop="workDate"
        header-align="center"
        align="center"
        label="参加时间">
      </el-table-column>
      <el-table-column
        prop="officeDate"
        header-align="center"
        align="center"
        label="获职时间">
      </el-table-column>
      <el-table-column
        prop="joinDate"
        header-align="center"
        align="center"
        label="进入时间">
      </el-table-column>
      <el-table-column
        prop="createTime"
        header-align="center"
        align="center"
        label="创建时间">
      </el-table-column>
      <el-table-column
        prop="createBy"
        header-align="center"
        align="center"
        label="创建者">
      </el-table-column>
      <el-table-column
        prop="updateTime"
        header-align="center"
        align="center"
        label="更新时间">
      </el-table-column>
      <el-table-column
        prop="updateBy"
        header-align="center"
        align="center"
        label="更新者">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
  </div>
</template>

<script>
  import AddOrUpdate from './easbasicteacher-add-or-update'
  export default {
    data () {
      return {
        dataForm: {
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    components: {
      AddOrUpdate
    },
    activated () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/eas/easbasicteacher/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'key': this.dataForm.key
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      // 删除
      deleteHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/eas/easbasicteacher/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
    }
  }
</script>
